package io;

import java.io.*;
import java.util.Scanner;

/*
* PrintWriter 的缺陷
* */
public class PWDemo {
    public static void main(String[] args) throws FileNotFoundException {
        //创建低级流-转换流-缓冲流-PW流
        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw,true);
        //扫描器
        Scanner sc=new Scanner(System.in);
        //循环写入
        while(true){
            String s=sc.nextLine();
            if("exit".equals(s)){
                break;
            }
            pw.print(s);
        }
        //关闭流
        pw.close();
    }
}
